Skip to content

fix(react): remove false ellipsis when text fits in Chrome#2206

Merged
maksym-shynkarenko merged 1 commit intodevelopfrom
fix-TextEllipsis-tooltip
Feb 5, 2026
Merged

fix(react): remove false ellipsis when text fits in Chrome#2206
maksym-shynkarenko merged 1 commit intodevelopfrom
fix-TextEllipsis-tooltip

Conversation

@maksym-shynkarenko
Copy link
Contributor

@maksym-shynkarenko maksym-shynkarenko commented Jan 20, 2026

Problem

Chrome incorrectly displayed ellipsis ("...") for TextEllipsis component with maxLines prop, even when text fit within the specified number of lines. This was particularly noticeable with short text using maxLines={2} or higher.

Root Cause

The .TextEllipsis:after pseudo-element with display: block (added in #1926 as a Safari workaround) caused Chrome to miscalculate overflow when combined with -webkit-line-clamp in multiline mode.

Solution

Changed the CSS selector from .TextEllipsis:after to .TextEllipsis:not(.TextEllipsis--multiline):after to apply the Safari workaround only to single-line ellipsis. This prevents the Chrome rendering bug while preserving the original Safari fix.

Result

  • ✅ Ellipsis now displays only when text genuinely exceeds the line count
  • ✅ Safari native tooltip workaround preserved for single-line mode

Video

Video: fix in Chrome and Safari
Screen.Recording.2026-02-03.at.16.08.25.1.mov
Video: responsiveness
Screen.Recording.2026-01-19.at.19.48.14.mov

Closes: Walnut #13167

@maksym-shynkarenko maksym-shynkarenko requested a review from a team January 20, 2026 17:07
@maksym-shynkarenko maksym-shynkarenko requested a review from a team as a code owner January 20, 2026 17:07
Copilot AI review requested due to automatic review settings January 20, 2026 17:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Chrome rendering bug where the TextEllipsis component incorrectly displayed ellipsis even when text fit within the specified maxLines. The solution moves -webkit-line-clamp application from static props to dynamic management within the ResizeObserver, measuring actual overflow and conditionally removing the property when no overflow exists.

Changes:

  • Removed static -webkit-line-clamp application from component props
  • Implemented dynamic -webkit-line-clamp management in ResizeObserver callback
  • Added maxLines to useEffect dependency array

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aws-amplify-us-east-1
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-2206.d15792l1n26ww3.amplifyapp.com

Bracciata
Bracciata previously approved these changes Jan 21, 2026
Copy link
Contributor

@Bracciata Bracciata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me!

Copy link
Contributor

@Zidious Zidious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR references closing https://github.com/dequelabs/walnut/issues/13260 but this fix seems unrelated to that, am I incorrect in thinking that?

@maksym-shynkarenko
Copy link
Contributor Author

This PR references closing dequelabs/walnut#13260 but this fix seems unrelated to that, am I incorrect in thinking that?

yeah, sorry, the wrong PR for that ticket, wil lremove it from PR description

@maksym-shynkarenko maksym-shynkarenko marked this pull request as draft January 21, 2026 17:14
@maksym-shynkarenko maksym-shynkarenko marked this pull request as ready for review February 3, 2026 14:35
@maksym-shynkarenko maksym-shynkarenko dismissed Zidious’s stale review February 3, 2026 14:39

Applied the solution .TextEllipsis:not(.TextEllipsis--multiline):after

Copy link
Contributor

@Zidious Zidious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - we'll want final 👀 from @anastasialanz

@maksym-shynkarenko maksym-shynkarenko merged commit fedc13a into develop Feb 5, 2026
9 checks passed
@maksym-shynkarenko maksym-shynkarenko deleted the fix-TextEllipsis-tooltip branch February 5, 2026 17:25
@anastasialanz
Copy link
Collaborator

anastasialanz commented Feb 5, 2026

I made an issue to add screenshots for this component.

#2229

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants